package com.kaifamiao.statements;

import java.util.Scanner;

public class Deer {
    public static void main(String[] args) {
        final Scanner s = new Scanner( System.in );

        int age = 0 ;
        // do { 循环体 } while ( 条件 );
        do {
            if( age < 0 || age > 150 ) {
                System.out.println( "你输入的年龄不符合正常人类的寿命范围，请重新输入" );
            } else {
                System.out.println( "请输入你的年龄:" );
            }
            age = s.nextInt();
        } while ( age < 0 || age > 150 );
        System.out.println( "第一个循环中输入的年龄: " + age );

        String msg1 = "请输入你的年龄:";
        String msg2 = "你输入的年龄不符合正常人类的寿命范围，请重新输入";
        boolean error = false;
        do {
            System.out.println( error ? msg2 : msg1 );
            age = s.nextInt();
        } while ( error = age < 0 || age > 150 );
        System.out.println( "第二个循环中输入的年龄: " + age );

        s.close();
    }
}
